{% extends "base.html" %}
{% load i18n %}
{% block title%}{% trans "luca_home_send_sms" %}{% endblock%}
{% block breadcrumbs%}<li>{% trans "luca_home_send_sms" %}</li>{% endblock%}
{% load staticfiles %}

 
{% block content %}
      {% if messages %}
	        {% for message in messages %}
	       		<div class="alert alert-success">
	        	 <a href="#" class="close" data-dismiss="alert">&times;</a>
	       			{{ message }}
	   			</div>
	        {% endfor %}  
	  {% endif %}    			
<div class="box-inner" ng-controller='smsController'>

       <div class="box-header well" data-original-title="">
                <h2><i class="glyphicon glyphicon-edit"></i> {% trans "luca_home_send_sms" %}</h2>
       </div>  
            <div class="box-content">
            <div class="row">
            <div class="col-sm-4">       	
          
                     <div class="form-group">
                    <label>
                    	{% trans "luca_template_content" %}
                    </label>
                                      
                    
                    	<select class="form-control required" ng-model="selectSmsTemplate" ng-change="templateChange()">
                    		<option value=0>{% trans "luca_template_select_template" %}</option>
                    		{% if templates_list %}
							    {% for template in templates_list %}
									<option value="{{template.id}}">{{template.name}}</option>						
							    {% endfor %}		
							{% endif %}
                    	</select>    
                    </div>
                    
   			
                     
                	<div class="form-group [[error_class]]">
                        <label>
                        	{% trans "luca_template_phone" %}
						</label>
                        <input type="text" class="form-control" disabled  ng-model="telephone" required >
                    </div>
                    <hr>

 			
     				<div ng-repeat="param in params">
		      			<div class="form-group"><input type="text" ng-model="params[param.id]"  class="form-control ng-invalid param_data_input [[param.id]]" placeholder="[[param.id]]" required ></div>	
		    		</div>
		    
                    <button type="button" class="btn btn-default" ng-click="templateSubmit()">{% trans "luca_sms_submit" %}</button>
                    <button type="button" class="btn btn-default" ng-click="templateReset()">{% trans "luca_sms_reset" %}</button>
	

            </div>
      		<div class="col-sm-1"></div>
            <div class="col-sm-5">
            	  <div class="form-group">
                        <label>
                        	{% trans "luca_customer_group" %}
						</label>
                       	<select class="form-control" ng-model='selectedGroup' ng-options="group for group in customers">
                 		  <option value="0">{% trans "luca_customer_select_group" %}</option> 
         				 </select>
          
                    </div>
                    
                       <div class="form-group">
                        <label>
                        	{% trans "luca_customer_location" %}
						</label>
                      <select class="form-control" ng-model='selectedLocation' ng-options="location for location in customers[selectedGroup]">
					<option value="">{% trans "luca_customer_select_location" %}</option> 
					  </select>
          
                    </div>
				
                    
                    <div class="form-group">
                        <label>
                        	{% trans "luca_customer_name" %}
						</label>
					
					
                       	<select class="chosen-select form-control" ng-options="item as item.name for item in customers[selectedGroup][selectedLocation]" ng-model="selectCustomer" ng-change="customerChange()">
                       		<option value="">{% trans "luca_customer_select" %}</option> 
         				 </select>
          
                    </div>
            	
            	
            	 <div class="form-group">
                        <label>{% trans "luca_template_content" %}</label>
                 <pre><p id="template_content" dynamic="template_content"></p></pre>
                 <br>
                 
                  <div class="center ajax_loading" ng-show="ajax-loading">
                  	<img src="{% static 'bootstrap/images/ajax.gif' %}">
                  </div>
                 <div class="alert alert-info" role="alert" dynamic="sms_result" ng-show="sms_result_box">
     			 </div>
   				 
                 </div>
            
			</div>
        </div>
        	
	</div>
	
	
</div>
{% endblock %}
